app.register.controller("UserRealnameCtrl", ["$rootScope", "$scope", "$location", "$timeout", "$window", "ToastMessage", "SecurityService", "Upload", function($rootScope, $scope, $location, $timeout, $window, ToastMessage, SecurityService, Upload) {
    $scope.loaded = !1,
    $scope.upload = function(file, type) {
        Upload.upload({
            url: app.res.url(8e3, "/pri/upload/idcard.jhtml"),
            data: {
                file: file,
                type: type
            }
        }).then(function(resp) {}, function(resp) {}, function(evt) {
            parseInt(100 * evt.loaded / evt.total)
        })
    }
    ,
    $scope.certRealname = function(event) {
        if (!app.util.isDisabled(event.target)) {
            app.util.setDisabled(event.target, !0);
            var params = {
                idcard: $scope.idcard,
                realname: $scope.realname,
                code: $scope.code
            };
            SecurityService.certByIDCard(params).success(function(data) {
                app.credential.refresh(),
                ToastMessage.show(data.message, data.success),
                data && data.success && $window.history.back(),
                app.util.setEnabled(event.target, !0)
            })
        }
    }
    ;
    var funs = {
        loadStatus: function() {
            SecurityService.status(function(data) {
                $scope.loaded = !0,
                data && data.success && ($scope.status = data.result,
                funs.formatStatus())
            })
        },
        formatStatus: function() {
            $scope.status && ($scope.loaded = !0,
            $scope.idcard = $scope.status.cert.idcard,
            $scope.realname = $scope.status.cert.name)
        }
    };
    $scope.status = SecurityService.cache("status"),
    funs.formatStatus(),
    funs.loadStatus()
}
]);
